import http from '@/utils/http'
import { DepAddParams, DepListParams, DepResponse, DepResponseData } from '../types/Department'
import { JobPeronsResponse } from '../types/Position'

enum API {
    DepList_URL = '/api/etp/branch/list',
    DepAdd_URL = '/api/etp/branch/add',
    DepEdit_URL = '/api/etp/branch/edit',
    DepStatus_URl = '/api/etp/branch/status',
    DepDelete_URL = '/api/etp/branch/delete',
    UserPerson_URL = '/api/acl/user/names'
}

// 获取部门列表
export const reqDepList = (data: DepListParams) => http.get<any, DepResponseData>(API.DepList_URL, { params: data })

// 新增部门
export const reqDepAdd = (data: DepAddParams) => http.post<any, DepResponse>(API.DepAdd_URL, data)

// 编辑部门
export const reqDepEdit = (data: DepAddParams) => http.patch<any, DepResponse>(API.DepEdit_URL, data)

// 编辑状态
export const reqDepStatus = (_id: string, status: boolean) => http.patch<any, DepResponse>(API.DepStatus_URl, { _id, status })

// 删除部门
export const reqDepDelete = (_id: string) => http.get<any, DepResponse>(API.DepDelete_URL + `?_id=${_id}`)

// 用户人列表
export const reqPersonList = () => http.get<any,JobPeronsResponse>(API.UserPerson_URL)
